using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Text;
using System.Windows.Forms;

namespace PrintPreviewDialogProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           PrintDocument document = new PrintDocument();
            document.PrintPage += new PrintPageEventHandler(document_PrintPage);
            printPreviewDialog1.Document = document;            
            printPreviewDialog1.ShowDialog();
        }
        private void document_PrintPage(object sender,
    PrintPageEventArgs e)
        {
            string text = richTextBox1.Text;
            Font printFont =
                new Font("Arial", 35,
                FontStyle.Regular);

            e.Graphics.DrawString(text, printFont,
                Brushes.Black, 0, 0);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog ppd = new PrintPreviewDialog();
            PrintDocument document = new PrintDocument();
            document.PrintPage += new PrintPageEventHandler(document_PrintPage);
            ppd.Document = document;
            ppd.ShowDialog();
        }

    }
}